package com.easyCode.sqlBuilder.sqlInfo;

import com.easyCode.sqlBuilder.SqlInfo;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;

/**
 * 提供数据库相关的相关sqlInfo
 * @author 大忽悠
 * @create 2022/11/8 19:22
 */
@Data
@Slf4j
public abstract class BaseDataBaseSqlInfo implements SqlInfo {
    /**
     * 数据库名
     */
    protected String dataBaseName;
    /**
     * 表集合
     */
    protected List<BaseTableSqlInfo> tableSqlInfoList=new CopyOnWriteArrayList<>();
    /**
     * 添加数据库创建的sql语句: CREATE DATABASE [IF NOT EXISTS] dbname;
     */
    protected Boolean createDataBase=Boolean.TRUE;

    @Override
    public String buildSql() {
        return doBuildSql();
    }

    protected abstract String doBuildSql();

    public void addTableSqlInfo(BaseTableSqlInfo...tableSqlInfos){
        tableSqlInfoList.addAll(List.of(tableSqlInfos));
    }
}
